;
;
;
;http://www.emacswiki.org/emacs/.durdn.office.el
;
;
; C-c t converts a reST txt file into html and opens the html
;
;;(defun restify (&optional n)
;;  (interactive)
;;  (shell-command
;;    (concat "D:\\installed\\python\\docutils-0.3.3\\tools\\rst2html.py "
;;            "\"" (buffer-file-name) "\" " "\""
;;            (file-name-sans-extension (buffer-file-name)) ".html" "\""))
;;  (find-file (concat (file-name-sans-extension (buffer-file-name)) ".html")))
;;(global-set-key "\C-ct"  'restify)

(defvar rst2simplehtml "c:/PROGRA~1/MOZILL~1/firefox.exe -new-tab"
(defvar rst2simplepreview "c:/PROGRA~1/MOZILL~1/firefox.exe -new-tab" "Program used to preview rst file in firefox.")

(defun restify ()
  "Show the simple html conversion of the current active region,
or of the entire buffer, if the region is not selected."
  (interactive)
  (with-output-to-temp-buffer "*simplehtml*"
    (shell-command-on-region
     (if mark-active (region-beginning) (point-min))
     (if mark-active (region-end) (point-max))
     "rst2html.py"
     standard-output)))

;; Use firefox to preview rst-mode files on windows
(defvar rst-firefox-preview "c:/PROGRA~1/MOZILL~1/firefox.exe -new-tab"
"Program used to preview rst file in firefox.")

(defun rst-compile-windows-file-preview ()
  "Compile command to convert reST file 
   into html and preview it in firefox"
  (interactive)
  (let* ((tmp-filename "c:/tmp/out.html")
	 (tmp1-filename "file:///c:/tmp/out.html")
	 (command (format "rst2html %s %s && %s %s"
			  buffer-file-name tmp-filename
			  rst-firefox-preview tmp1-filename)))
    (start-process-shell-command "rst-firefox-preview" nil command)
    ;; Note: you could also use 
    ;; (compile command) to view the compilation
    ;; output.
    ))

